#ifndef _CALLBACK_H
#define _CALLBACK_H
#include "google/protobuf/message.h"
#include <functional>
#include <string>
using std::string;

typedef std::tr1::function<void(void*,google::protobuf::Message*)> Message_CallBack;

class MessageCallBack;
class MessageDispather
{
public:
	static Message_CallBack* getMessageCallBack(const string& name);
	template<typename T>
	static void RegisterMessageCallBack(const Message_CallBack& messagecallbak);
	static std::map<std::string,Message_CallBack> s_messageDispatcher;
	static void init();
};

template<typename T>
void MessageDispather::RegisterMessageCallBack( const Message_CallBack& messagecallbak )
{
	const string& name = T::descriptor()->full_name();
	s_messageDispatcher[name] = messagecallbak;
}

class loginRequestCallBack
{
public:
	static void process(void* extData,google::protobuf::Message* message) ;
};
class logoutRequestCallBack
{
public:
	static void process(void* extData,google::protobuf::Message* message) ;
};
class heartbeatCallBack
{
public:
	static void process(void* extData,google::protobuf::Message* message) ;
};


#endif